package 笔试题.笔试360;

import java.util.Arrays;
import java.util.Scanner;

public class 神枪手 {
    static class Main {
        public static void main(String[] args) {
            Scanner sc = new Scanner(System.in);
            String s = sc.nextLine();
            int count = Integer.parseInt(s);
            String s1 = sc.nextLine();
            String[] score = s1.split(" ");
            long[] array = Arrays.stream(score).mapToLong(i -> Long.parseLong(i)).toArray();
            long sum = 0;
            for (int i = 0; i < array.length - 1; i++) {
                for (int j = i + 1; j < array.length ; j++) {
                    sum += array[i] | array[j];
                }
                sum += array[i];
            }
            sum += array[array.length - 1];
            System.out.print(sum);
        }
    }
}
